import request from '@/utils/request'

////////////////////////////////////////////////////////////////地图使用start
//查询设定地震--根据任务ID和类型type
export function getAllSetting(query) {
    return request({
        url: '/settingSeismic/all',
        method: 'get',
        params: query
    })
}

//保存数据
export function saveSettingSeismicPoint(data) {
    return request({
        url: '/settingSeismic/saveSettingSeismicPoint',
        method: 'post',
        data: data
    })
}

//批量保存点状设定地震数据
export function saveSettingSeismicPoint2(data) {
    return request({
        url: '/settingSeismic/saveSettingSeismicPoint2',
        method: 'post',
        data: data
    })
}

//根据ID查询点状设定地震
export function getSettingSeismicPointById(id) {
    return request({
        url: '/settingSeismic/getSettingSeismicPointById?id='+id,
        method: 'get',
    })
}

//修改点状设定地震
export function updateSettingSeismicPoint(settingSeismicPoint) {
    return request({
        url: '/settingSeismic/updateSettingSeismicPoint',
        method: 'post',
        data: settingSeismicPoint
    })
}

//逻辑删除点状设定地震
export function deleteSettingSeismicPoint(ssId) {
    return request({
        url: '/settingSeismic/deleteSettingSeismicPoint?ssId='+ssId,
        method: 'post',
    })
}

//保存断层设定地震数据
export function saveSettingSeismicFault(data) {
    return request({
        url: '/settingSeismic/saveSettingSeismicFault',
        method: 'post',
        data: data
    })
}

//删除断层设定地震
export function deleteSettingSeismicFault(sfId) {
    return request({
        url: '/settingSeismic/deleteSettingSeismicFault?sfId='+sfId,
        method: 'post',
    })
}

//保存公里格网设定地震数据
export function saveSettingSeismicGrid(data) {
    return request({
        url: '/settingSeismic/saveSettingSeismicFault',
        method: 'post',
        data: data
    })
}

//删除公里格网设定地震
export function deleteSettingSeismicGrid(sfId) {
    return request({
        url: '/settingSeismic/deleteSettingSeismicFault?sfId='+sfId,
        method: 'post',
    })
}

//查询任务信息
export function getTaskInfoById(taskId){
    return request({
        url: '/settingSeismic/getSpaceRange?taskId='+taskId,
        method: 'get'
    })
}

//查询任务区域断层信息
export function getFaultById(taskId){
    return request({
        url: '/settingSeismic/getFault?taskId='+taskId,
        method: 'get'
    })
}

//根据任务ID查询任务区域行政区划code列表
export function getAllCodeListByTaskId(taskId){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getAllCodeListByTaskId/'+taskId,
        method: 'get'
    })
}

//根据任务ID获取任务区域内的相交的断层信息
export function getIntersectionFaultByTaskId(taskId){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getIntersectionFaultByTaskId?taskId='+taskId,
        method: 'get'
    })
}

//判断经纬度是否在面内部（不包括边线）
export function isTaskRegionContainsLonLat(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/isTaskRegionContainsLonLat',
        method: 'get',
        params: query
    })
}

//判断经纬度是否在任务区域边线上（不包括区域内部）
export function isTaskRegionTouchesLonLat(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/isTaskRegionTouchesLonLat',
        method: 'get',
        params: query
    })
}

//根据全部经纬度字符串获取任务区域内的经纬度字符串（多点相交）
export function getLonLatsStringByTaskId(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getLonLatsStringByTaskId',
        method: 'post',
        data: query
    })
}

//根据经纬度字符串查询全部经纬度及行政区划省市区县信息字符串（经度,纬度,省,市,区县,乡镇;）
export function queryAllLonLatProvinceCityCountyNameStringByLonLatsString(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryAllLonLatProvinceCityCountyNameStringByLonLatsString',
        method: 'post',
        data: query
    })
}

//根据经纬度查询行政区划省市区县信息字符串（省,市,区县,乡镇）
export function queryProvinceCityCountyNameStringByLonLat(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryProvinceCityCountyNameStringByLonLat',
        method: 'get',
        params: query
    })
}

//根据任务ID获取任务范围最小矩形的经纬度值数组
export function getTaskRegionExtent(taskId){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getTaskRegionExtent/'+taskId,
        method: 'get'
    })
}

//获取任务范围的正方形公里格网网格线和震中位置经纬度列表（以右上角为初始点）
export function getSquareGridCenterLonLatList(taskId,kilometer){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getSquareGridCenterLonLatList/'+taskId+"/"+kilometer,
        method: 'get'
    })
}

//创建地震影响场
export function createInfluenceEllipse(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/createInfluenceEllipse',
        method: 'get',
        params: query
    })
}

//根据taskId，查询全部评估结果列表
export function getResultTotalByTaskId(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getResultTotalByTaskId',
        method: 'get',
        params: query
    })
}

//根据taskId和序号，查询全部评估结果详情列表
export function getResultTotalDetailByTaskIdNum(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getResultTotalDetailByTaskIdNum',
        method: 'get',
        params: query
    })
}

//根据taskId，查询全部设定地震的震级列表
export function queryInfluencefliedLevelListByTaskId(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryInfluencefliedLevelListByTaskId',
        method: 'get',
        params: query
    })
}

//根据任务ID、序号，查询震级、角度列表
export function queryInfluencefliedLevelAngleList(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryInfluencefliedLevelAngleList',
        method: 'get',
        params: query
    })
}

//根据taskId、震级、查询类型、序号总个数，按序号从小到大排序查询全部评估结果（未选择角度：最小值,最大值）
export function queryAllEvaluateResultTotalDetails(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryAllEvaluateResultTotalDetails',
        method: 'get',
        params: query
    })
}

//根据查询类型、taskId、震级、角度、序号、经度、纬度，查询评估结果（选择角度：1条数据）
export function queryEvaluateResultTotalDetailsByAngle(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryEvaluateResultTotalDetailsByAngle',
        method: 'get',
        params: query
    })
}

//根据taskId、震级、角度、序号、经度、纬度，按烈度从小到大排序查询地震影响场
export function queryInfluencefliedEllipse(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/queryInfluencefliedEllipse',
        method: 'get',
        params: query
    })
}

//根据经纬度查询最近断层切线角度（与正东方向的夹角，[0,180]）
export function getClosestFaultageAngleByLonLat(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getClosestFaultageAngleByLonLat',
        method: 'get',
        params: query
    })
}

//根据全部经纬度字符串批量查询最近断层切线角度列表（与正东方向的夹角，[0,180]）
export function getClosestFaultageAngleListByLonLatsString(query){
    return request({
        url: '/earthquakeLossesEstimation/earthquakeSetting/getClosestFaultageAngleListByLonLatsString',
        method: 'post',
        data: query
    })
}

//查询人员伤亡分布图数据
export function getPbeInjuriesByTaskIdAndIntensity(taskId,dzIntensity){
    return request({
        url: '/casualty/getPbeInjuriesByTaskIdAndIntensity?taskId='+taskId+'&dzIntensity='+dzIntensity,
        method: 'get',
    })
}

//查询经济损失分布图数据
export function getPbeLossesByTaskIdAndIntensity(taskId,dzIntensity){
    return request({
        url: '/economic/getPbeLossesByTaskIdAndIntensity?taskId='+taskId+'&dzIntensity='+dzIntensity,
        method: 'get',
    })
}

//查询需紧急安置人数分布图数据
export function getPbeByTaskIdAndIntensity(taskId,dzIntensity){
    return request({
        url: '/count/getPbeByTaskIdAndIntensity?taskId='+taskId+'&dzIntensity='+dzIntensity,
        method: 'get',
    })
}

//查询人员死亡按区县、乡镇统计表
export function countPbeInjuries(taskId,dzIntensity,qcType){
    let query = {
        taskId:taskId,
        dzIntensity:dzIntensity,
        qcType:qcType
    }
    return request({
        url: '/taskRegionQuery/countPbeInjuries',
        method: 'get',
        params: query
    })
}

//查询经济损失按区县、乡镇统计表
export function countPbeLosses(taskId,dzIntensity,qcType){
    let query = {
        taskId:taskId,
        dzIntensity:dzIntensity,
        qcType:qcType
    }
    return request({
        url: '/taskRegionQuery/countPbeLosses',
        method: 'get',
        params: query
    })
}

//查询需紧急安置人数按区县、乡镇统计表
export function countPbePlant(taskId,dzIntensity,qcType){
    let query = {
        taskId:taskId,
        dzIntensity:dzIntensity,
        qcType:qcType
    }
    return request({
        url: '/taskRegionQuery/countPbeInjuries',
        method: 'get',
        params: query
    })
}

//查询抗震能力分布图层数据
export function getSeiCapCalculation(taskId,dzIntensity,type){
    return request({
        url: '/preAssessResult/getSeiCapCalculation?taskId='+taskId+'&dzIntensity='+dzIntensity+'&type='+type,
        method: 'get',
    })
}

//获取区县致死性差异性分布数据
export function getLethalityDifferenceFinalValue(taskId){
    return request({
        url: '/lethalityDifference/getFinalValue?taskId='+taskId ,
        method: 'get',
    })
}

//根据任务ID查询全部烈度计算结果列表
export function getYpgResultSlopeNewIntensityList(taskId){
    return request({
        url: '/count/getYpgResultSlopeNewIntensityList?taskId='+taskId,
        method: 'get',
    })
}

//根据任务ID查询缓冲区内相交部分的道路数据、滑坡计算结果网格
export function getYpgResultSlopeRoadByTaskId(taskId,dzIntensity){
    return request({
        url: '/count/getYpgResultSlopeRoadByTaskId?taskId='+taskId+"&dzIntensity="+dzIntensity,
        method: 'post',
    })
}

//根据任务ID查询滑坡缓冲区
export function getYpgResultSlopeBufferByTaskId(taskId){
    return request({
        url: '/count/getYpgResultSlopeBufferByTaskId?taskId='+taskId,
        method: 'post',
    })
}

//根据任务ID查询缓冲区内相交部分的道路数据统计结果
export function getYpgResultRoadListByTaskId(taskId,dzIntensity){
    return request({
        url: '/count/getYpgResultRoadListByTaskId?taskId='+taskId+'&dzIntensity='+dzIntensity,
        method: 'post',
    })
}

//根据任务ID查询震后交通情况分析
export function getTrafficAnalysisByTaskId(taskId,dzIntensity){
    return request({
        url: '/count/getTrafficAnalysisByTaskId?taskId='+taskId+"&dzIntensity="+dzIntensity,
        method: 'get',
    })
}

//保存震后交通情况分析
export function saveTrafficAnalysis(data) {
    return request({
        url: '/count/saveTrafficAnalysis',
        method: 'post',
        data: data
    })
}

//更新震后交通情况分析
export function updateTrafficAnalysis(data) {
    return request({
        url: '/count/updateTrafficAnalysis',
        method: 'post',
        data: data
    })
}

//导入地震影响场--上传空间矢量数据文件
export function influencefliedUpload(data) {
    return request({
        url: '/influencefliedImport/influencefliedUpload',
        method: 'post',
        data: data
    })
}

//导入地震影响场--根据任务id查询全部设定地震明细数据
export function getSettingSeismicDetailsByTaskId(taskId) {
    return request({
        url: '/influencefliedImport/getSettingSeismicDetailsByTaskId/'+taskId,
        method: 'get'
    })
}
////////////////////////////////////////////////////////////////地图使用end




// 查询所有任务列表
export function getAllTask(query) {
  return request({
    url: '/preAssessResult/taskPage',
    method: 'get',
    params: query
  })
}
// 查询待分配任务列表
export function getUndistributedTask(query) {
  return request({
    url: '/preAssessResult/undistributedTaskPage',
    method: 'get',
    params: query
  })
}
// 获取任务详情
export function getPreAssessTaskInfo(taskId) {
  return request({
    url: '/preAssessResult/getPreAssessTaskInfo?taskId=' + taskId,
    method: 'get'
  })
}

// 获取当前父任务是否有子任务
export function getSubTask(taskId) {
  return request({
    url: '/preAssessTask/getSubTask?parentTaskId=' + taskId,
    method: 'get'
  })
}

// 分配子任务-是否有设定地震
export function isHaveSetEarthquake(taskId) {
  return request({
    url: '/preAssessResult/isHaveSetEarthquake?taskId=' + taskId,
    method: 'get'
  })
}
// 分配子任务-分配任务
export function assignment(taskId) {
  return request({
    url: '/preAssessResult/assignment?taskId=' + taskId,
    method: 'get'
  })
}
// 设定地震列表
export function setEarthquakeCensus(taskId) {
  return request({
    url: '/preAssessResult/setEarthquakeCensus?taskId=' + taskId,
    method: 'get'
  })
}
// 设定地震列表-查看明细
export function getDetailPage(params) {
  return request({
    url: '/preAssessResult/getDetailPage',
    method: 'get',
    params
  })
}
// 设定地震列表-查看明细-弹框删除
export function detailDelete(ids) {
  return request({
    url: `/preAssessResult/detailDelete/${ids}`,
    method: 'post'
  })
}
// 设定地震列表-删除
export function setEarthquakeDelete({taskId, faultNum}) {
  return request({
    url: `/preAssessResult/setEarthquakeDelete?taskId=${taskId}&faultNum=${faultNum}`,
    method: 'post'
  })
}
// 查询所有模型基本信息      
export function intensityRelation(taskId) {
  return request({
    url: `/intensityRelation/all?taskId=${taskId}`,
    method: 'get'
  })
}
// /intensityRelation/getDefaultByTaskId
export function getDefaultByTaskId(taskId) {
  return request({
    url: `/intensityRelation/getDefault1ByTaskId?taskId=${taskId}`,
    method: 'get'
  })
}

// 查询烈度衰减关系模型详情
export function getModelById(id) {
  return request({
    url: `/intensity/getModelById?id=${id}`,
    method: 'get'
  })
}

// 查询人员伤亡计算模型详情
export function getCasualtyModelById(id) {
  return request({
    url: `/casualty/getModelById?id=${id}`,
    method: 'get'
  })
}

// 查询经济损失计算模型详情
export function getEconomicModelById(id) {
  return request({
    url: `/economic/getModelById?id=${id}`,
    method: 'get'
  })
}

// 查询物资需求评估模型详情
export function getMaterialConomicModelById(id) {
  return request({
    url: `/material/getModelById?id=${id}`,
    method: 'get'
  })
}
   
// 查询救援力量需求评估模型详情
export function getRescueForceConomicModelById(id) {
  return request({
    url: `/rescueForce/getModelById?id=${id}`,
    method: 'get'
  })
}
   
// 查询需安置人员计算模型详情
export function getResettlementModelById(id) {
  return request({
    url: `/resettlement/getModelById?id=${id}`,
    method: 'get'
  })
}

// 查询烈度衰减关系所有模型
export function getAllModel(queryParams) {
  return request({
    url: '/intensityRelation/getAllModel',
    method: 'get',
    params: queryParams
  })
}

// 选择烈度衰减关系模型
export function selectModel(taskId,modelId,type) {
  return request({
    url: `/intensityRelation/selectModel?taskId=${taskId}&modelId=${modelId}&type=${type}`,
    method: 'get'
  })
}

// 新增烈度衰减关系模型
export function saveIntensityAttenuation(data) {
  return request({
    url: '/intensityRelation/saveIntensityAttenuation',
    method: 'post',
    data
  })
}

// 生成地震影响场-烈度衰减关系模型
export function countEqIntensity(data) {
  const {taskId, modelId, range} = data
  return request({
    url: `/count/countEqIntensity?taskId=${taskId}&modelId=${modelId}&range=${range}` ,
    method: 'post'
  })
}

// 生成地震影响场-手工填写地震影响场长短轴长度
export function saveSettingSeismicProcess({taskId, entity, range}) {
  return request({
    url: `/intensityRelation/saveSettingSeismicProcess?taskId=${taskId}&range=${range}`,
    method: 'post',
    data: entity
  })
}

// 生成建筑物抗震能力分布
export function seiCapCalculation(taskId,type) {
  return request({
    url: `/preAssessResult/seiCapCalculation?taskId=${taskId}&type=${type}`,
    method: 'post',
  })
}


// 建筑易损性矩阵-列表
export function matrixList(params) {
  return request({
    url: `/preAssessResult/matrixList`,
    method: 'get',
    params
  })
}
// 建筑易损性矩阵-选择-弹框列表
export function matrixChoiceList(params) {
  const {province, city, county} = params
  return request({
    url: `/preAssessResult/matrixChoiceList`,
    method: 'get',
    params
  })
}
// 建筑易损性矩阵-查看-弹框列表
export function matrixSee(params) {
  return request({
    url: `/preAssessResult/matrixSee`,
    method: 'get',
    params
  })
}
// 建筑易损性矩阵-弹框列表-详情
export function matrixChoiceListDetail(params) {
  return request({
    url: `/preAssessResult/matrixChoiceListDetail`,
    method: 'get',
    params
  })
}

// 建筑易损性矩阵-弹框列表-保存
export function matrixSave(data) {
  return request({
    url: `/preAssessResult/matrixSave`,
    method: 'post',
    data
  })
}

// 人员伤亡模型计算
export function countIntensityAndStructureOfArea(data) {
  return request({
    url: `/casualty/countIntensityAndStructureOfArea`,
    method: 'post',
    data
  })
}
export function savePbeInjuries(data) {
  return request({
    url: `/casualty/savePbeInjuries`,
    method: 'post',
    data
  })
}
export function casualtiesCalculate(data) {
  return request({
    url: `/casualty/calculate`,
    method: 'post',
    data
  })
}


// 经济损失模型计算
export function savePbeLosses(data) {
  return request({
    url: `/economic/savePbeLosses`,
    method: 'post',
    data
  })
}
export function economicCalculate(data) {
  return request({
    url: `/economic/calculate`,
    method: 'post',
    data
  })
}

// 需紧急安置人数模型计算-1
export function AzMath(data) {
  return request({
    url: `/count/AzMath`,
    method: 'post',
    data
  })
}

// 需紧急安置人数模型计算-2
export function AzCount(data) {
  const {taskId, modelId} = data
  return request({
    url: `/count/AzCount?taskId=${taskId}&modelId=${modelId}`,
    method: 'post'
  })
}

// 需紧急安置人数模型计算-12
export function newCalculate(data) {
  const {taskId, range} = data
  return request({
    url: `/count/calculate?taskId=${taskId}&range=${range}`,
    method: 'post'
  })
}


// 救援力量需求模型计算
export function countRescueForce(data) {
  const {taskId, modelId} = data
  return request({
    url: `/count/countRescueForce?taskId=${taskId}&modelId=${modelId}`,
    method: 'post'
  })
}

// 救援物资需求模型计算
export function countMaterial(data) {
  const {taskId, modelId} = data
  return request({
    url: `/count/countMaterial?taskId=${taskId}&modelId=${modelId}`,
    method: 'post'
  })
}
// /count/countLandslide
// String taskId,String type,String dzIntensity,String parameter
export function countLandslide(data) {
  return request({
    url: `/count/countLandslide`,
    method: 'post',
    data
  })
}

// 生成建筑物抗震能力分析
export function seiCapCalOfBuilding(taskId){
  return request({
    url: '/preAssessResult/seiCapCalculation?taskId='+taskId,
    method: 'get'
  })
}

//生成区县致死性差异性分布
export function createFinalValue(taskDistrict,taskNum){
  return request({
      url: '/lethalityDifference/createFinalValue?taskDistrict='+taskDistrict+"&taskNum="+taskNum ,
      method: 'post'
  })
}

// 评估及结果修正
export function getAllResult(params){
  return request({
      url: '/result/all',
      method: 'get',
      params
  })
}
export function getAllNoPage(params){
  return request({
      url: '/result/allNoPage',
      method: 'get',
      params
  })
}

// 评估及结果修正提交
export function updateResult(data){
  return request({
      url: '/result/updateAll',
      method: 'post',
      data
  })
}

// 查看详细评估结果
export function getAllDetailsResult(taskId){
  return request({
      url: '/result/allDetails?taskId='+taskId,
      method: 'get'
  })
}

export function getSlopeData(query) {
  return request({
      url: '/count/getParam0Version',
      method: 'get',
      params: query
  })
}

export function getVersionListData(query) {
  return request({
      url: '/basic/versionList',
      method: 'get',
      params: query
  })
}

export function getBusinessVersionListData(query) {
  return request({
      url: '/basic/businessVersionList',
      method: 'get',
      params: query
  })
}
//黄土高原模型计算
export function count2(data) {
    return request({
        url: '/count/count2',
        method: 'post',
        data: data
    })
}
// 更新设定地震序号
export function updateEarthquakeCensus(data) {
    return request({
        url: '/preAssessResult/updateEarthquakeCensus',
        method: 'post',
        data
    })
}

// 查询选择计算范围taskId
export function getRangeByTaskId(taskId) {
  return request({
      url: `/count/getRangeByTaskId/${taskId}`,
      method: 'get'
  })
}
// 选择计算范围清空计算结果
export function deleteDateByTaskId(taskId) {
  return request({
      url: `/count/deleteDateByTaskId/${taskId}`,
      method: 'get'
  })
}